package com.tfswue.hql.controller;

import com.tfswue.hql.entity.User;
import jakarta.servlet.http.HttpSession;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
public class UserController {

    private final User user;

    @Autowired
    public UserController(User user) {
        this.user = user;
    }

    @RequestMapping("/user")
    public User getUser() {
        return user;
    }

    @RequestMapping("/session")
    public String session(HttpSession  session) {
        session.setAttribute("username", "hql");
        System.out.println(session.getAttribute("username"));
        return "session end";
    }
}